ext.define('extension.utils', function() {

var strings = {
    NOCENS: 'This URL is not filtered.',
    NORESRC: 'This webpage has no Flash elements.',
    NOREQ: 'No Flash plugins found.',
    REQCNT: '{0} Flash plugin{1} found.',
    PTRNDUP: 'The pattern {0} already exists.',
    LIVEMODE: '{0} Live Filtering',
    CLPSMODE: '{0} console',
    TITLE: 'FlashControl Inspector - '
};

function mapKeyword(s) {
    return {
        'blacklisted': 'denied',
        'whitelisted': 'allowed',
        'gblacklisted': 'denied',
        'gwhitelisted': 'allowed',
        'sameDomain': 'same domain',
        'patternlistB': 'white',
        'patternlistD': 'black'
    }[s] || s;
}

function showOverlay(m, s) {
    var n = $q(s);
    var e = n.querySelectorAll('.message-panel');
    for (var i = 0; i < e.length; i++)
        e[i].parentNode.removeChild(e[i]);
    if (m) {
        e = $x('message');
        e.querySelector('.text').textContent = m;
        if (n.firstElementChild)
            n.insertBefore(e, n.firstElementChild);
        else
            n.appendChild(e);
    }
}

function showGlass(s, c) {
    var g = document.createElement('div');
    g.className = 'glass-pane resize-' + s;
    document.body.appendChild(g);
    document.addEventListener('mouseup', function _mu(e) {
        document.removeEventListener('mouseup', _mu);
        document.removeEventListener('mousemove', c);
        document.body.removeChild(g);
    });
    document.addEventListener('mousemove', c);
}

function showSummary(t, m, s) {
    var n = $q(s);
    n.textContent = '';
    if (t) {
        var e = document.createElement('div');
        e.className = t;
        n.appendChild(e);
    }
    n.appendChild(document.createTextNode(m));
}

return {
    stringMap: mapKeyword,
    strings: strings,
    overlay: showOverlay,
    glass: showGlass,
    summary: showSummary
};

});
